﻿namespace Hidistro.UI.SaleSystem.Tags
{
    using Hidistro.Core;
    using Hidistro.Core.Enums;
    using Hidistro.Entities;
    using Hidistro.Entities.Commodities;
    using Hidistro.Membership.Context;
    using Hidistro.SaleSystem.Catalog;
    using System;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class YB_Stroe_TopProduct : WebControl
    {

        private int categoryid = 0;
        protected override void Render(HtmlTextWriter writer)
        {
            this.xml = new XmlDocument();
            xml.Load(HttpContext.Current.Request.MapPath(HiContext.Current.GetSkinPath() + "/config/YB_Store.xml"));
            writer.Write(this.RendHtml());
        }

        public string RendHtml()
        {
            int.TryParse(this.Page.Request.QueryString["Categoryid"], out categoryid);

            XmlNode node = xml.SelectSingleNode(string.Format("//Store[@cid='{0}']", categoryid));
            StringBuilder builder = new StringBuilder();

            if (node != null)
            {
                builder.Append(node["StoreTop"].InnerXml);
            }
            return builder.ToString();
        }

        public XmlDocument xml { get; set; }
    }
}

